package EventManager;

/**
 * An abstract Administrator request. Most admin functions are of this type and won't be processed unless are 
 * issued by an admin.
 * 
 * @author Yury Kitaev
 *
 */
public abstract class AdminRequest extends Request
{

	private Administrator issuer;

	
	public AdminRequest (Administrator issuer)
	{
		super();
		setIssuer(issuer);
	}
	
	/**
	 * Only an administrator can issue Admin requests.
	 * @param issuer
	 */
	public void process (Administrator issuer)
	{
		if (null == issuer)
		{
			throw new NullPointerException("The issuer of the admin request must be identified!");
		}
	}
	
	@Override
	public void process()
	{
		// Refuse requests by non-administrators
		setStatus(RequestStatus.Refused);
	}
	
	@Override
	public String toString() 
	{
		return this.getClass().toString() +  " issued by " + issuer + "; status = " + getStatus().toString().toUpperCase();
	}

	public Administrator getIssuer() 
	{
		return issuer;
	}

	public void setIssuer(Administrator issuer) 
	{
		this.issuer = issuer;
	}
}
